package com.chj.comp.common.rabbitmq.sender;

import com.chj.comp.common.rabbitmq.core.AbstractSender;
import com.chj.comp.common.rabbitmq.message.MessageEntity;
import com.chj.comp.common.rabbitmq.queue.MqFanoutQueue;
import com.chj.comp.common.rabbitmq.util.MessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 *
  * @Description: 发布订阅模型-广播类型消息发送
  * @author cuihui
  * @date 2022-06-09
  *
 */
@Slf4j
public class MqFanoutSender extends AbstractSender<Message> {

    public MqFanoutSender(RabbitTemplate rabbitTemplate) {
        super(rabbitTemplate);
    }

    @Override
    public String send(Message message) {
        // 发送消息
        rabbitTemplate.convertAndSend(MqFanoutQueue.EXCHANGE_NAME, "", message);
        return message.getMessageProperties().getMessageId();
    }

}
